package org.jeecg.modules.wlhy.gas.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.wlhy.gas.entity.HyShippingNoteGas;
import org.jeecg.modules.wlhy.gas.mapper.HyShippingNoteGasMapper;
import org.jeecg.modules.wlhy.gas.service.IHyShippingNoteGasService;
import org.springframework.stereotype.Service;

/**
 * @Description: hy_shipping_note_gas
 * @Author: jeecg-boot
 * @Date:   2021-08-14
 * @Version: V1.0
 */
@Service
public class HyShippingNoteGasServiceImpl extends ServiceImpl<HyShippingNoteGasMapper, HyShippingNoteGas> implements IHyShippingNoteGasService {

    @Override
    public HyShippingNoteGas getByShippingId(String shippingId) {
        HyShippingNoteGas one = this.getOne(new QueryWrapper<HyShippingNoteGas>().eq("shipping_id", shippingId));
        return one;
    }

    @Override
    public boolean checkDriverNameExist(String driverId){
        if(StringUtils.isNotBlank(driverId)){
            int one = this.count(new QueryWrapper<HyShippingNoteGas>().eq("driver_id", driverId));
            return one > 0 ;
        }
        return  false;
    }

    @Override
    public HyShippingNoteGas getByIdForUpdate(String id) {
        return baseMapper.getByIdForUpdate(id);
    }

    @Override
    public HyShippingNoteGas getByShippingIdForUpdate(String shippingId) {
        return baseMapper.getByShippingIdForUpdate(shippingId);
    }

    @Override
    public IPage<HyShippingNoteGas> getPageList(Page<HyShippingNoteGas> page,
                                                QueryWrapper<HyShippingNoteGas> queryWrapper) {
        IPage<HyShippingNoteGas> pageList = baseMapper.getPageList(page, queryWrapper);
        return pageList;
    }

    @Override
    public boolean checkRecharge(HyShippingNoteGas shippingNoteGas) {
        if(shippingNoteGas == null){
            return false;
        }
        String gasStatus = shippingNoteGas.getGasStatus();
        if("2".equals(gasStatus) || "9".equals(gasStatus)){
            return true;
        }
        return false;
    }
}
